package sctu.edu.java.year2016.team05.lizixin.day20160605.LianXi3;

/**
 * Created by home on 2016/6/6.
 * 用throw语句抛出异常
 */
public class Example3{
 final static double PI =3.14;
    public void computerArea(double r)throws Exception{
        if(r<=20.0){
            throw new Exception("程序异常：\n半径为："+r+"半径不能小于20.");

        }else{
            double cicleArea=PI*r*r;
            System.out.println("半径是"+r+"的圆的面积是："+cicleArea);

        }
    }

    public static void main(String[] args) {
        Example3 ex=new Example3();
        try{
            ex.computerArea(10);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }

}
